home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Temático 40 Febrero 2004.iso / DOS / ntfs / nt / ntfstypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-11  |  3.8 KB  |  144 lines

  1. /*
  2.  *  ntfstypes.h
  3.  *  This file defines four things:
  4.  *   - generic platform independent fixed-size types (e.g. ntfs_u32)
  5.  *   - specific fixed-size types (e.g. ntfs_offset_t)
  6.  *   - macros that read and write those types from and to byte arrays
  7.  *   - types derived from OS specific ones
  8.  *
  9.  *  Copyright (C) 1996 Martin von L÷wis
  10.  */
  11.  
  12. #ifdef NTFS_IN_LINUX_KERNEL
  13. /* get installed types if we compile the kernel*/
  14. #include <linux/fs.h>
  15. #endif
  16.  
  17. #ifdef _MSC_VER
  18. #include <nttypes.h>
  19. #endif
  20.  
  21. #ifdef HAVE_CONFIG_H
  22. #include "config.h"
  23. #endif
  24.  
  25. #if defined(i386) || defined(__i386__)
  26.  
  27. /* unsigned integral types */
  28. #ifndef NTFS_INTEGRAL_TYPES
  29. #define NTFS_INTEGRAL_TYPES
  30. typedef unsigned char      ntfs_u8;
  31. typedef unsigned short     ntfs_u16;
  32. typedef unsigned int       ntfs_u32;
  33. typedef unsigned long long ntfs_u64;
  34. #endif
  35.  
  36. /* unicode character type */
  37. #ifndef NTFS_WCHAR_T
  38. #define NTFS_WCHAR_T
  39. typedef unsigned short     ntfs_wchar_t;
  40. #endif
  41. /* file offset */
  42. #ifndef NTFS_OFFSET_T
  43. #define NTFS_OFFSET_T
  44. typedef unsigned long long ntfs_offset_t;
  45. #endif
  46. /* UTC */
  47. #ifndef NTFS_TIME64_T
  48. #define NTFS_TIME64_T
  49. typedef unsigned long long ntfs_time64_t;
  50. #endif
  51. /* This is really unsigned long long. So we support only volumes up to 2 TB */
  52. #ifndef NTFS_CLUSTER_T
  53. #define NTFS_CLUSTER_T
  54. typedef unsigned int ntfs_cluster_t;
  55. #endif
  56.  
  57. /* Macros reading unsigned integers from a byte pointer */
  58. /* these should work for all little endian machines */
  59. #define NTFS_GETU8(p)      (*(ntfs_u8*)(p))
  60. #define NTFS_GETU16(p)     (*(ntfs_u16*)(p))
  61. #define NTFS_GETU24(p)     (NTFS_GETU32(p) & 0xFFFFFF)
  62. #define NTFS_GETU32(p)     (*(ntfs_u32*)(p))
  63. #define NTFS_GETU64(p)     (*(ntfs_u64*)(p))
  64.  
  65. /* Macros writing unsigned integers */
  66. #define NTFS_PUTU8(p,v)      (*(ntfs_u8*)(p))=(v)
  67. #define NTFS_PUTU16(p,v)     (*(ntfs_u16*)(p))=(v)
  68. #define NTFS_PUTU24(p,v)     NTFS_PUTU16(p,(v) & 0xFFFF);\
  69.                              NTFS_PUTU8(((char*)p)+2,(v)>>16)
  70. #define NTFS_PUTU32(p,v)     (*(ntfs_u32*)(p))=(v)
  71. #define NTFS_PUTU64(p,v)     (*(ntfs_u64*)(p))=(v)
  72.  
  73. /* Macros reading signed integers, returning int */
  74. #define NTFS_GETS8(p)        ((int)(*(char*)(p)))
  75. #define NTFS_GETS16(p)       ((int)(*(short*)(p)))
  76. #define NTFS_GETS24(p)       (NTFS_GETU24(p) < 0x800000 ? (int)NTFS_GETU24(p) : (int)(NTFS_GETU24(p) | 0xFF000000))
  77.  
  78. #define NTFS_PUTS8(p,v)      NTFS_PUTU8(p,v)
  79. #define NTFS_PUTS16(p,v)     NTFS_PUTU16(p,v)
  80. #define NTFS_PUTS24(p,v)     NTFS_PUTU24(p,v)
  81. #define NTFS_PUTS32(p,v)     NTFS_PUTU32(p,v)
  82.  
  83. #else
  84. #error Put your machine description here
  85. #endif
  86.  
  87. /* architecture independent macros */
  88.  
  89. /* PUTU32 would not clear all bytes */
  90. #define NTFS_PUTINUM(p,i)    NTFS_PUTU64(p,i->i_number);\
  91.                              NTFS_PUTU16(((char*)p)+6,i->sequence_number)
  92.  
  93. /* system dependent types */
  94. #ifdef __linux__
  95. /* We always need kernel types, because glibc makes them of different size */
  96. #include <asm/posix_types.h>
  97. /* Avoid a type redefinition with future include of glibc <stdlib.h> */
  98. #undef __FD_ZERO
  99. #undef __FD_SET
  100. #undef __FD_CLR
  101. #undef __FD_ISSET
  102. #ifndef NTMODE_T
  103. #define NTMODE_T
  104. typedef __kernel_mode_t ntmode_t;
  105. #endif
  106. #ifndef NTFS_UID_T
  107. #define NTFS_UID_T
  108. typedef __kernel_uid_t ntfs_uid_t;
  109. #endif
  110. #ifndef NTFS_GID_T
  111. #define NTFS_GID_T
  112. typedef __kernel_gid_t ntfs_gid_t;
  113. #endif
  114. #ifndef NTFS_SIZE_T
  115. #define NTFS_SIZE_T
  116. typedef __kernel_size_t ntfs_size_t;
  117. #endif
  118. #ifndef NTFS_TIME_T
  119. #define NTFS_TIME_T
  120. typedef __kernel_time_t ntfs_time_t;
  121. #endif
  122. #else
  123. #ifndef _MSC_VER
  124. #ifdef HAVE_SYS_CDEFS_H
  125. /* hack to get BSD system header files to work */
  126. #include <sys/cdefs.h>
  127. #endif
  128. #include <sys/types.h>
  129. #include <sys/time.h>
  130. #include <sys/stat.h>
  131. typedef mode_t ntmode_t;
  132. typedef uid_t ntfs_uid_t;
  133. typedef gid_t ntfs_gid_t;
  134. typedef size_t ntfs_size_t;
  135. typedef time_t ntfs_time_t;
  136. #endif /* _MSC_VER */
  137. #endif /* __linux__ */
  138.  
  139. /*
  140.  * Local variables:
  141.  * c-file-style: "linux"
  142.  * End:
  143.  */
  144.